package com.tabjin.rfidsocket.authority.shiro;

import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authc.credential.SimpleCredentialsMatcher;

/**
 * @author tabjin
 * create at 2020/12/17 11:54
 * @program rfid_socket
 * @description SimpleCredentialsMatcher已经对CredentialsMatcher做了基础实现
 */
public class CredentialMatcher extends SimpleCredentialsMatcher {
    /**
     * 重写密码校验规则
     * @param token
     * @param info
     * @return
     */
    @Override
    public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
        UsernamePasswordToken usernamePasswordToken = (UsernamePasswordToken) token;
        String password = new String(usernamePasswordToken.getPassword());
        String dbPassword = (String) info.getCredentials();
        return this.equals(password, dbPassword);
    }
}
